package br.com.emefs1.ftgourmet.menu;

import android.app.Activity;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.view.Gravity;
import android.view.View;

@SuppressWarnings("deprecation")
public class NavActionBarDrawerToggle extends ActionBarDrawerToggle {

	private static final int DEFAULT_HOME = android.R.id.home;
	private static final int DEFAULT_INDENT = 0;
	private static final int DEFAULT_GRAVITY = Gravity.RIGHT
			| Gravity.CENTER_VERTICAL;

	private Activity activity;
	private DrawerLayout drawerLayout;

	public NavActionBarDrawerToggle(Activity activity,
			DrawerLayout drawerLayout, int drawerImageRes,
			int openDrawerContentDescRes, int closeDrawerContentDescRes) {

		super(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes,
				closeDrawerContentDescRes);
		this.activity = activity;
		this.drawerLayout = drawerLayout;
	}

	/**
	 * Metodo para exibir o titulo quando o menu estiver fechado.
	 * 
	 * */
	public void onDrawerClosed(View drawerView) {
		super.onDrawerClosed(drawerView);
		activity.getActionBar().setTitle(activity.getTitle());
		activity.invalidateOptionsMenu();

	}

	/**
	 * Metodo para exibir a Mensagem do Menu quando janela estiver aberta.
	 * 
	 * */
	public void onDrawerOpened(View drawerView) {
		super.onDrawerOpened(drawerView);
		activity.getActionBar().setTitle("Selecione ");
		activity.invalidateOptionsMenu();
	}

	/*
	 * @Override public boolean onOptionsItemSelected(MenuItem item) { if (item
	 * != null && item.getItemId() == DEFAULT_HOME) { if
	 * (drawerLayout.isDrawerOpen(DEFAULT_GRAVITY)) {
	 * drawerLayout.closeDrawer(DEFAULT_GRAVITY); } else {
	 * drawerLayout.openDrawer(DEFAULT_GRAVITY); } } return false; }
	 */

}
